package com.cx.controller;

import com.cx.entity.Book;
import com.cx.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@ResponseBody
@RequestMapping(produces = "application/json;charset=utf-8")
public class BookController {
    @Autowired
    private BookService bookService;

    @RequestMapping("/selectAllBook")
    List<Book> selectAllBook() {
        return bookService.selectAllBook();
    }

    @RequestMapping("/selectBookById")
    Book selectBookById(int bookId) {
        return bookService.selectBookById(bookId);
    }
    @RequestMapping("/deleteBookById")
    int deleteDept(int bookId) {
        return bookService.deleteDept(bookId);
    }
    @RequestMapping("/updateBookById")
    int updateDept(Book book) {
        return bookService.updateDept(book);
    }
    @RequestMapping("/insertBookById")
    int insertDept(Book book) {
        return bookService.insertDept(book);
    }
}
